use actix_web::{Responder, HttpResponse, get};

#[get("/")]
async fn hello() -> impl Responder {
    HttpResponse::Ok().json(r#"{
        "message": "hello"
    }"#)
}

#[cfg(test)]
mod tests {
    use actix_web::{test, App, http::header::ContentType};

    use super::*;

    #[actix_web::test]
    async fn test_hello_get() {
        let app = test::init_service(App::new().service(hello)).await;
        let req = test::TestRequest::get().uri("/")
            .insert_header(ContentType::json())
            .to_request();
        let res = test::call_service(&app, req).await;
        assert_eq!(res.status(), 200);
    }
}
